﻿@using SCMS.Resource
@model IEnumerable<SCMS.UI.Models.ViewSalaryPayment>

@if (Model.Count() > 0)
{
    <div id="tablewrapper">
        <div id="tableheader">
            <div class="search">
                <b>@Resources.Global_String_SearchBy:</b><br />
                <select id="columns4" onchange="sorter4.search('query4')">
                </select>
                <input type="text" id="query4" onkeyup="sorter4.search('query4')" />
            </div>
            <span class="details">
                <div>
                    @Resources.Global_String_Records <span id="startrecord4"></span>-<span id="endrecord4"></span> @Resources.Global_String_Of <span id="totalrecords4">
                    </span>
                </div>
            </span>
        </div>
        <br />
        <br />
        <br />
        <table width="98%" align="center" cellpadding="0" cellspacing="0" border="0" id="table4"
            class="tinytable">
            <thead>
                <tr>
                    <th>
                        <h3>
                            @Resources.Global_String_SPMNo</h3>
                    </th>
                    <th>
                        <h3>
                            @Resources.Global_String_Month</h3>
                    </th>
                    <th>
                        <h3>
                            @Resources.Global_String_Year</h3>
                    </th>
                    <th>
                        <h3>
                            @Resources.Budget_CategoryList_ProjectNo</h3>
                    </th>
                    <th><h3>@Resources.Global_String_Status</h3></th><th><h3>@Resources.Global_String_StatusDate</h3></th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr onclick="sendRequest('/SalaryPament/ViewSalaryPaymentDetails?id=@item.EntitySalaryP.Id&checkPost=true', 'FundPostingDiv', 'loading')" style=" cursor:pointer;">
                        <td>
                            @item.EntitySalaryP.RefNumber
                        </td>
                        <td align="center">
                            @item.EntitySalaryP.PayrollMonth
                        </td>
                        <td>
                            @item.EntitySalaryP.PayrollYear
                        </td>
                        <td align="left">
                            @item.EntitySalaryP.SalaryBudgetlines.First().ProjectBudget.BudgetCategory.ProjectDonor.ProjectNumber
                        </td>
                        <td align="center">
                            @if (item.EntitySalaryP.IsAuthorized)
                            { 
                                <b style="color: Green; font-weight: bold;">
                                    @Resources.Global_String_StatusAU
                                </b>
                            }
                            else if (item.EntitySalaryP.IsRejected)
                            {
                                <b style="color: Red; font-weight: bold;">
                                    @Resources.Global_String_StatusRJ
                                </b>
                            }
                            else if (item.EntitySalaryP.IsReviewed)
                            {
                                @Html.Raw(Resources.Global_String_StatusRV)
                            }
                            else if (item.EntitySalaryP.FundsPosted)
                            { 
                                <b style="color: Blue; font-weight: bold;">
                                    @Resources.Global_String_StatusFP
                                </b>
                            }
                            else
                            { 
                                @Html.Raw(Resources.Global_String_StatusCR)
                            }
                        </td>
                        <td align="right">
                            @if (item.EntitySalaryP.IsAuthorized)
                            { 
                                @item.EntitySalaryP.AuthorizedOn.Value.ToString("dd/MM/yyyy")
                            }
                            else if (item.EntitySalaryP.IsRejected)
                            {
                                if (item.EntitySalaryP.IsReviewed)
                                { 
                                    @item.EntitySalaryP.AuthorizedOn.Value.ToString("dd/MM/yyyy")
                                }
                                else
                                { 
                                    @item.EntitySalaryP.ReviewedOn.Value.ToString("dd/MM/yyyy")
                                }
                            }
                            else if (item.EntitySalaryP.IsReviewed)
                            {
                                @item.EntitySalaryP.ReviewedOn.Value.ToString("dd/MM/yyyy")
                            }
                            else if (item.EntitySalaryP.FundsPosted)
                            { 
                                @item.EntitySalaryP.PostedOn.Value.ToString("dd/MM/yyyy")
                            }
                            else
                            { 
                                @item.EntitySalaryP.PreparedOn.Value.ToString("dd/MM/yyyy")
                            }                            
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <div id="tablefooter">
            <div id="tablenav4">
                <div>
                    <img src="../../Content/images/pager/first.gif" width="16" height="16" alt="@Resources.Global_String_FirstPage"
                        onclick="sorter4.move(-1,true)" />
                    <img src="../../Content/images/pager/previous.gif" width="16" height="16" alt="@Resources.Global_String_PreviousPage"
                        onclick="sorter4.move(-1)" />
                    <img src="../../Content/images/pager/next.gif" width="16" height="16" alt="@Resources.Global_String_NextPage"
                        onclick="sorter4.move(1)" />
                    <img src="../../Content/images/pager/last.gif" width="16" height="16" alt="@Resources.Global_String_LastPage"
                        onclick="sorter4.move(1,true)" />
                </div>
                <div>
                    <select id="pagedropdown">
                    </select>
                </div>
                <div>
                    <a href="javascript:sorter4.showall()">@Resources.Global_String_ViewAll</a>
                </div>
            </div>
            <div id="tablelocation">
                <div>
                    <select onchange="sorter4.size(this.value)">
                        <option value="5">5</option>
                        <option value="10">10</option>
                        <option value="20" selected="selected">20</option>
                        <option value="50">50</option>
                        <option value="100">100</option>
                    </select>
                    <span>@Resources.Global_String_EntriesPerPage</span>
                </div>
                <div class="page">
                    @Resources.Global_String_Page <span id="currentpage4"></span>@Resources.Global_String_Of <span id="totalpages4"></span>
                </div>
            </div>
        </div>
    </div>
}
else
{
    <i style="text-align: center;">@Resources.FundPosting_SPMList_NoSPMsToPost</i>
}
 
